﻿using CommonServiceLocator;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Jn698._45GWTool.Services;
using Jn698._45GWTool.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using WebFirst.Entities;

namespace Jn698._45GWTool.ViewModels.Controls
{
    public class ProxyTransmitViewModel:ViewModelBase
    {
        private GWCmdMakeUpService GWCmdMakeUpService = new GWCmdMakeUpService();

		private ObservableCollection<GWCmdMakeUp> gWCmdMakeUpList;

		public ObservableCollection<GWCmdMakeUp> GWCmdMakeUpList
        {
			get { return gWCmdMakeUpList; }
			set { Set(ref gWCmdMakeUpList,value); }
		}

        public ProxyTransmitViewModel()
        {
            GWCmdMakeUpList=new ObservableCollection<GWCmdMakeUp>(GWCmdMakeUpService.SelectByOAD("090700FF"));
        }

        public RelayCommand<int> MouseDoubleClickCommand
        {
            get
            {
                var command = new RelayCommand<int>((index) =>
                {
                    if (GWCmdMakeUpList[index].SubItemName.Equals("端口通信控制块"))
                    {
                        ProxyTransmitCommView proxyTransmitCommView = new ProxyTransmitCommView();
                        if (proxyTransmitCommView.ShowDialog()==true)
                        {
                            GWCmdMakeUpList[index].DataValue = ProxyTransmitCommViewModel.commControl;
                        }
                    }
                });
                return command;
            }
        }

    }
}
